package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);comment:用户名"`
	Password string `gorm:"type:varchar(32);comment:密码"`
}

type Realname struct {
	gorm.Model
	UserId int    `gorm:"type:int(10);comment;comment:用户id"`
	Name   string `gorm:"type:varchar(20);comment:真实姓名"`
	IdCard string `gorm:"type:char(18);comment:身份证号"`
}

func (u *User) UserInfo(username string) error {
	return DB.Where("username=?", username).Limit(1).Find(&u).Error
}

func (ur *Realname) RealnameCreate() error {
	return DB.Create(&ur).Error
}

func (ur *Realname) RealnameFind(name string, IdCard string) error {
	return DB.Where("name=? or id_card=?", name, IdCard).Find(&ur).Error
}
